
var MyCalendar = function() {
    const arr = []
    return {
        arr: arr
    }
};

/** 
 * @param {number} startTime 
 * @param {number} endTime
 * @return {boolean}
 */
MyCalendar.prototype.book = function(startTime, endTime) {
    if (MyCalendar.arr.length > 0) {
        let count = -1
        arr.forEach((element, index) => {
            (element[0] > startTime && count < 0) ? count = index : undefined;
        });
        if (arr[count - 1][1] < endTime) {
            arr.splice(count, 0 , [startTime, endTime])
            return true
        } else {
            return false
        }
    } else {
        arr.push([startTime,endTime])
        return true
    }
};

/** 
 * Your MyCalendar object will be instantiated and called as such:
 * var obj = new MyCalendar()
 * var param_1 = obj.book(startTime,endTime)
 */